package demo5;

interface IFlying{
    void fly();
}
interface ISwimming{
    void swim();
}
interface IRun{
    void run();
}
abstract class Animal{
    private String name;
    private int age;
    /*public void eat(){
//        System.out.println(this.name + "正在吃饭！");
    }*/
    public Animal(String name , int age){
        this.name = name;
        this.age = age;
    }
    public abstract void eat();

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }
}
class Dog extends Animal implements IRun,ISwimming{
    public Dog(String name,int age){
        super(name,age);
    }
    @Override
    public void swim() {
        System.out.println(this.getName() + "正在狗刨！");
    }

    @Override
    public void run() {
        System.out.println(this.getName() + "正在用四条腿跑！");
    }

    @Override
    public void eat() {
        System.out.println(this.getName() + "正在吃狗粮！");
    }
}
class Bird  extends Animal implements IFlying{
    public Bird(String name,int age){
        super(name,age);
    }
    public void eat(){
        System.out.println(this.getName() + "正在吃鸟粮！");
    }
    public void fly(){
        System.out.println(this.getName() + "正在用翅膀飞！");
    }
}
class Robot implements IRun{
    @Override
    public void run() {
        System.out.println("机器人正在跑！");
    }
}


public class Test {
    public static void test1(Animal animal){
        animal.eat();
    }
    public static void testIFly(IFlying iflying){
        iflying.fly();
    }
    public static void testIRun(IRun irun){
        irun.run();
    }
    public static void testISwimming(ISwimming iswimming){
        iswimming.swim();
    }

    public static void main(String[] args) {
        Animal animal1 = new Bird("小鸟",1);
        Animal animal2 = new Dog("小狗",3);
        IRun run = new Robot();
        test1(animal1);
        testIFly(new Bird("小鸟",2));
        test1(animal2);
        testIRun(new Dog("小狗",3));
        testISwimming(new Dog("小狗",3));
        testIRun(run);


    }
}
